package com.bruip.controller;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @author 王若龙
 * @CreateTime 2022-09-07 20:26
 */
//将当前类标识为异常处理的组件
@ControllerAdvice
public class ExceptionController {

    @ExceptionHandler(ArithmeticException.class)
    public String handleException(Throwable ex, Model model){
        model.addAttribute("ex", ex);
        return "error";
    }
}
